package com.homework.Tools;

import java.math.BigDecimal;

public class Arr_calculate {
  public static BigDecimal arr_sum(double[] arr) {

    BigDecimal sum = new BigDecimal(0);
    for (double x : arr) {
      sum = sum.add(BigDecimal.valueOf(x));
    }
    return sum;
  }

  public static BigDecimal arr_multiply(double[] arr){
    BigDecimal mul = new BigDecimal(0);
    for (double x : arr) {
      mul = mul.multiply(BigDecimal.valueOf(x));
    }
    return mul;
  }

  public static void main(String[] args) {
    //
    double[] arr = {0.1, 0.2, 0.3, 0.6, 0.5};
    System.out.println(Arr_calculate.arr_sum(arr));
    System.out.println(Arr_calculate.arr_multiply(arr));
  }
}
